﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;

namespace AudioEffectBox
{
    public class BackupStream : Stream
    {
        private Stream _MainStream;
        private Stream _BackupStream;

        public BackupStream(Stream mainStream,Stream backupStream)
        {
            if (mainStream == null) throw new ArgumentException("Main Stream cannot be null");
            if (backupStream == null) throw new ArgumentException("Backup Stream cannot be null");

            if (!mainStream.CanWrite) throw new ArgumentException("Main Stream must be writeable");
            if (!backupStream.CanWrite) throw new ArgumentException("Backup Stream must be writeable");

            this._MainStream = mainStream;
            this._BackupStream = backupStream;
        }

        public override bool CanRead
        {
            get { return false; }
        }

        public override bool CanSeek
        {
            get { return false; }
        }

        public override bool CanWrite
        {
            get { return true; }
        }

        public override void Flush()
        {
            //nothing
        }

        public override long Length
        {
            get { throw new NotImplementedException(); }
        }

        public override long Position
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override int Read(byte[] buffer, int offset, int count)
        {
            throw new NotImplementedException();
        }

        public override long Seek(long offset, SeekOrigin origin)
        {
            throw new NotImplementedException();
        }

        public override void SetLength(long value)
        {
            throw new NotImplementedException();
        }

        public override void Write(byte[] buffer, int offset, int count)
        {
            _MainStream.Write(buffer
                , offset, count);
            _BackupStream.Write(buffer
                , offset, count);            
        }
    }
}
